package com.xiaozhen.sso.feign.fallback;

import com.xiaozhen.common.core.domain.R;
import com.xiaozhen.common.core.domain.system.SysUser;
import com.xiaozhen.sso.feign.SysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * HISTORY
 *
 * @author zhenweisheng
 * @date 2021/8/5 16:59
 * @description:
 */
public class SysUserServiceFallback implements FallbackFactory<SysUserService> {

    private static final Logger log = LoggerFactory.getLogger(SysUserServiceFallback.class);

    @Override
    public SysUserService create(Throwable throwable) {
        log.error("系统用户调用失败:{}", throwable.getMessage());
        return new SysUserService() {
            @Override
            public R<SysUser> selectByUsername(String username) {
                return R.fail("获取用户信息失败:" + throwable.getMessage());
            }
        };
    }
}
